import 'package:guochaoapp/model/banner_entity.dart';

bannerEntityFromJson(BannerEntity data, Map<String, dynamic> json) {
	if (json['success'] != null) {
		data.success = json['success'];
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['data'] != null) {
		data.data = new List<BannerData>();
		(json['data'] as List).forEach((v) {
			data.data.add(new BannerData().fromJson(v));
		});
	}
	if (json['sign'] != null) {
		data.sign = json['sign'];
	}
	return data;
}

Map<String, dynamic> bannerEntityToJson(BannerEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['success'] = entity.success;
	data['msg'] = entity.msg;
	data['code'] = entity.code;
	if (entity.data != null) {
		data['data'] =  entity.data.map((v) => v.toJson()).toList();
	}
	data['sign'] = entity.sign;
	return data;
}

bannerDataFromJson(BannerData data, Map<String, dynamic> json) {
	if (json['cover'] != null) {
		data.cover = json['cover'].toString();
	}
	return data;
}

Map<String, dynamic> bannerDataToJson(BannerData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['cover'] = entity.cover;
	return data;
}